import { useReactive } from "ahooks";
import { useModel } from "umi";
import compress from "gql-compress";

const useDeleteMemberStructure = () => {
    const { graphqlFetch } = useModel("global");

    const state = useReactive({
        loading: false,
    });

    // 加载组织所有已认证成员信息
    const deleteMemberStructure = async (omUuid, callback) => {
        if (!omUuid) return;
        state.loading = true;
        let res = await graphqlFetch({
            query,
            variables: {
                omUuid,
            },
        });
        callback && callback(res);
        state.loading = false;
        return res;
    };

    return { ...state, deleteMemberStructure };
};

const query = compress(`mutation MyMutation(
    $omUuid: UUID!
) {
    deleteMembersStructureByOmUuid(
        input: { omUuid: $omUuid }
    ) {
        clientMutationId
    }
}`);

export default useDeleteMemberStructure;
